package net.opslog.web.client.views;

import net.opslog.web.client.models.LogEntry;
import net.opslog.web.client.widgets.LogTable;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.user.client.ui.Label;

public class MainViewImpl extends Composite implements MainView {

	private static MainViewImplUiBinder uiBinder = GWT
			.create(MainViewImplUiBinder.class);

	interface MainViewImplUiBinder extends UiBinder<Widget, MainViewImpl> {
	}

	private Presenter presenter;

	@UiField
	LogTable logTable;
	@UiField
	Label userLabel;

	public MainViewImpl() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setLogFormat(String logFormat) {
		logTable.setLogFormat(logFormat);
	}

	@Override
	public void setUserInfo(String userInfo) {
		userLabel.setText(userInfo);
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;

	}

	@Override
	public void setLogDataProvider(AsyncDataProvider<LogEntry> logDataProvider) {
		logDataProvider.addDataDisplay(logTable.getCellTable());

	}
}
